package com.yc.post.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yc.base.BaseServiceImpl;
import com.yc.post.entity.Post;
import com.yc.post.mapper.PostMapper;
import com.yc.post.service.IPostService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 后台岗位表 服务实现类
 * </p>
 *
 * @author bao
 * @since 2021-12-09
 */
@Service
public class PostServiceImpl extends BaseServiceImpl<PostMapper, Post> implements IPostService {
    @Override
    public boolean create(Post post) {
        return save(post);
    }

    @Override
    public boolean createBatch(List<Post> postList) {
        return saveBatch(postList);
    }

    @Override
    public boolean delete(List<Long> ids) {
        return removeByIds(ids);
    }

    @Override
    public boolean update(Post post) {
        return updateById(post);
    }

    @Override
    public Post queryById(Long id) {
        return getById(id);
    }

    @Override
    public List<Post> selectList() {
        QueryWrapper<Post> wrapper = new QueryWrapper<>();
        wrapper.lambda().orderByDesc(Post::getId);
        return list(wrapper);
    }

    @Override
    public IPage<Post> selectPage(IPage<Post> page) {
        QueryWrapper<Post> wrapper = new QueryWrapper<>();
        wrapper.lambda().orderByDesc(Post::getId);
        return page(page, wrapper);
    }
}
